package com.snimay.redis;

import org.springframework.stereotype.Service;

/**
 * Created by on 2017/3/1.
 */
@Service
@Deprecated
public class RedisService {
	

/*	@Autowired
	RedisService redisService;
	
    @Autowired
    StringRedisTemplate stringRedisTemplate;


    @Resource(name = "stringRedisTemplate")
    ValueOperations<String, String> valOpsStr;

    @Autowired
    RedisTemplate<Object, Object> redisTemplate;

    @Resource(name = "redisTemplate")
    ValueOperations<Object, Object> valOpsObj;

    *//**
     * 根据指定key获取String
     * @param key
     * @return
     *//*
    public String getStr(String key){
        return valOpsStr.get(key);
    }
    
    *//**
     * 设置Str缓存
     * @param key
     * @param val
     *//*
    public void setStr(String key, String val){
        valOpsStr.set(key,val);
    }

    *//**
     * 删除指定key
     * @param key
     *//*
    public void del(String key){
        stringRedisTemplate.delete(key);
    }

    *//**
     * 根据指定o获取Object
     * @param o
     * @return
     *//*
    public Object getObj(Object o){
        return valOpsObj.get(o);
    }

    *//**
     * 设置obj缓存
     * @param o1
     * @param o2
     *//*
    public void setObj(Object o1, Object o2){
        valOpsObj.set(o1, o2);
    }

    *//**
     * 删除Obj缓存
     * @param o
     *//*
    public void delObj(Object o){
        redisTemplate.delete(o);
    }
    
    
    public Map getPermission() {
    	CurrentUserUtils currentUserUtils = CurrentUserUtils.getInstance();
    	String str = redisService.getStr((String) currentUserUtils.getObj());
    	return new Gson().fromJson(str, Map.class);
    }
    
    public void setPermission(String key,String token,Map permission) {
    	this.deletPermission(key);
    	CurrentUserUtils currentUserUtils = CurrentUserUtils.getInstance();
    	currentUserUtils.serObj(token);
    	redisService.setStr(key, token);
		redisService.setStr(token, new Gson().toJson(permission));
    }
    
    public void deletPermission(String key) {
		key = redisService.getStr(key);
		if(key!=null) {
			String obj = redisService.getStr(key);
			if(obj!=null)
			redisService.del(obj);
		}
    }
    
    
    
    
    
    */
    
    
    
    
    
    

}